←Select platform

Recognize(int,ITemplateForm,int,IEnumerable<Field>) Method

Summary

Performs processing on the IRecognitionForm on the page number and fields provided as parameters.

Syntax
C#
C++/CLI
Python
public void Recognize( 
   int recognitionPageNumber, 
   ITemplateForm templateForm, 
   int templatePageNumber, 
   IEnumerable<Field> fields 
) 
public:  
   void Recognize( 
      Int32 recognitionPageNumber, 
      ITemplateForm^ templateForm, 
      Int32 templatePageNumber, 
      IEnumerable<Field^>^ fields 
   ) 

Parameters

recognitionPageNumber

Integer that represents the page number in the recognition form's Pages collection.

templateForm

The template form object.

templatePageNumber

Integer that represents the page number in the template form Pages collection.

fields

A generic collection of Field to be processed in this IRecognitionForm.

Remarks

The results of recognizing the fields on this filled-in form can be accessed from the Field.Result property.

When the Recognize method is invoked, fields provided as a parameter are aligned and processed in the filled-in form.

Note

The following example is a snippet of a larger example project. To run the larger example project, follow the work flow laid out in the OMREngine example. You can also download the complete Visual Studio 2017 project.

Example
C#
using Leadtools; 
using Leadtools.Barcode; 
using Leadtools.Codecs; 
 
using Leadtools.Forms.Processing.Omr; 
using Leadtools.Forms.Processing.Omr.Fields; 
using Leadtools.Ocr; 
 
public static List<IRecognitionForm> RecognizeMultipleForms(ITemplateForm template, OmrEngine engine) 
{ 
   string[] inputs = Directory.GetFiles(Path.Combine(LEAD_VARS.ImagesDir, @"Forms\OMR Processing\Exam\filled\")); 
   List<IRecognitionForm> recognizedForms = new List<IRecognitionForm>(); 
 
   // each filled form is recognized separately 
   for (int i = 0; i < inputs.Length; i++) 
   { 
      string fileToRecognize = inputs[i]; 
      IRecognitionForm formToRecognize = engine.CreateRecognitionForm(); 
      formToRecognize.Name = string.Format("Exam {0}", i + 1); 
 
      using (RasterImage fileToRecognizeImage = engine.EnginesObject.RasterCodecs.Load(fileToRecognize)) 
      { 
         for (int j = 0; j < fileToRecognizeImage.PageCount; j++) 
         { 
            fileToRecognizeImage.Page = j + 1; 
            formToRecognize.Pages.AddPage(fileToRecognizeImage); 
         } 
 
         formToRecognize.Recognize(template); 
      } 
 
      for (int j = 0; j < formToRecognize.Pages[0].Fields.Count; j++) 
      { 
         OmrField field = formToRecognize.Pages[0].Fields[j] as OmrField; 
 
         if (field != null) 
         { 
            OmrFieldResult omrFieldResult = (OmrFieldResult)field.Result; 
 
            Console.Write(omrFieldResult.Text + "\t"); 
         } 
      } 
      Console.WriteLine(); 
 
      recognizedForms.Add(formToRecognize); 
 
 
   } 
 
   return recognizedForms; 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; 
} 
Requirements

Target Platforms

Help Version 22.0.2023.3.31
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Forms.Processing.Omr Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.